from django.shortcuts import render

# Create your views here.
from rest_framework.viewsets import GenericViewSet
from django_filters.rest_framework import DjangoFilterBackend
from utils.Ops_mixins import OpsListModelMixin, OpsUpdateModelMixin
from alarm.models import Alarm_info
from alarm.serializer import AlarmInfoModelSerializerr
from utils.Ops_page import HostPage
from rest_framework.filters import SearchFilter


class AlarmView(OpsListModelMixin, OpsUpdateModelMixin, GenericViewSet):
    queryset = Alarm_info.objects.filter().order_by("-id")
    serializer_class = AlarmInfoModelSerializerr

    pagination_class = HostPage
    filter_backends = [SearchFilter, DjangoFilterBackend]
    search_fields = ['alarm_name', 'alarm_info', 'alarm_time']
    filterset_fields = ['is_handle', 'is_ignore']

